package com.mku.wms_service.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mku.wms_service.common.QueryPageParam;
import com.mku.wms_service.common.Response;
import com.mku.wms_service.dto_vo.LoginDTO;
import com.mku.wms_service.entity.User;
import com.mku.wms_service.service.IUserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author maoxx
 * @since 2024-11-22
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;


    @PostMapping("/login")
    @ApiOperation("用户登录")
    public Response<User> login(@RequestBody LoginDTO loginDTO) {
        return userService.login(loginDTO);
    }

    @ApiOperation("根据id查询用户信息")
    @GetMapping("/findByNo")
    public Response<User> findByNo(@RequestParam("no") String no) {
        return userService.findByNo(no);
    }


    @ApiOperation("分页查询")
    @PostMapping("/listPage")
    public Response<Page<User>> listPage(@RequestBody QueryPageParam qp2) {
        return userService.listPage(qp2);
    }

    @ApiOperation("编辑/添加人员信息")
    @PostMapping
    public Response<User> save(@RequestBody User user) {
        return userService.add(user);
    }


    @ApiOperation("删除人员信息")
    @DeleteMapping("/{id}")
    public Response<User> delete(@PathVariable("id") Integer id) {
        return userService.delete(id);
    }




}
